package xkp.lesson1;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

public class Client {
    public static void main(String[] args) throws IOException {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress("127.0.0.1",8888));
        //socketChannel.
        ByteBuffer buffer = ByteBuffer.allocate(1024);
        //read会阻塞
        //配置为非阻塞
        socketChannel.configureBlocking(false);
        //当配置为非阻塞的话，面临的问题为 此处通道不管读还是没读到数据，都不会阻塞，如何和得知读到数据?????
        socketChannel.read(buffer);
        System.out.println("------------------------");
    }
}
